package com.flyee.communicate.character{
	
	import com.flyee.communicate.Handler;
	import com.flyee.io.socket.command.down.CommandDown;
	import com.flyee.ro.commanddown.MoveAvatarDown;
	import com.flyee.service.pool.ObjectCollection;
	import com.flyee.utils.Obsevable;

	public class MoveAvatarHandler extends Obsevable implements Handler{
		
		public function MoveAvatarHandler(){
			super();
		}
		
		public function process(cmd:CommandDown) : void{
			var command : MoveAvatarDown = cmd as MoveAvatarDown;
	        if(command.avatar.listPane!=null){
		        setChanged();	        
		        notifyObsevers("move",command.avatar.avatarId, command.avatar.startX, command.avatar.startY, command.avatar.listPane);
	        }else{
	        	if(ObjectCollection.getCharacter(command.avatar.avatarId)==null){
	        		setChanged();
	        		notifyObsevers("addAvatar",command.avatar);
	        	}
	        }
		}
		
	}
}